package com.qidian.mes.tools.controller;

import com.qidian.common.pojo.MESResult;
import com.qidian.mes.pojo.ToolLedger;
import com.qidian.mes.pojo.ToolType;
import com.qidian.mes.tools.service.ToolsLegerService;
import com.qidian.mes.tools.service.ToolsTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author 任超
 * Time 2024/10/21 11:31
 */
@RestController
@RequestMapping("/ledger")
@CrossOrigin
public class ToolsLedgerController {

    @Autowired
    private ToolsLegerService toolsLegerService;

    @GetMapping("/list")
    public MESResult list(ToolLedger toolLedger, @RequestParam(defaultValue = "1") int page, @RequestParam(defaultValue = "10") int limit) {
        return toolsLegerService.selectList(toolLedger,page,limit);
    }

    @PutMapping("/add")
    public MESResult add(@RequestBody ToolLedger toolLedger){
        return toolsLegerService.addToolLedger(toolLedger);
    }

    @PutMapping("/update")
    public MESResult update(@RequestBody ToolLedger toolLedger){
        return toolsLegerService.updateToolLedger(toolLedger);
    }

    @GetMapping("/selectById")
    public MESResult selectById(Long toolLedgerId){
        return toolsLegerService.selectById(toolLedgerId);
    }

    @PutMapping("/delete")
    public MESResult delete(Long toolLedgerId){
        return toolsLegerService.deleteToolLedger(toolLedgerId);
    }

    @GetMapping("/selectByType")
    public MESResult selectByType(int status){
        return toolsLegerService.selectByType(status);
    }
}
